<?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/osl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @category   design_blank
 * @package    Mage
 * @copyright  Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
 * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 */
?>
<?php
/**
 * Template for Mage_Page_Block_Html
 */
/* For Background Image */
$resource = Mage::getSingleton('core/resource');
$read = $resource->getConnection('catalog_read');
$background = $resource->getTableName('background');
$select = $read->select()
        ->from(array('cp'=>$background))
        ->where('cp.background_id = ?', '1')
        ->where('cp.status = ?', '1');

$background_image_array = $read->fetchAll($select);
if(isset($background_image_array[0]['filename'])){
	$background_image = "background-image:url(".$this->getUrl('media').$background_image_array[0]['filename'].");background-repeat:no-repeat;background-position:50% 0%; background-attachment: fixed;";
	Mage::getSingleton('core/session')->setBackground('yes');
} 
else {
  Mage::getSingleton('core/session')->setBackground('no');
  $background_image ="background:#EFEFE9;";
}

$_pid			= Mage::getSingleton('core/session')->getProductID(); 
$_product = Mage::getModel('catalog/product')->load($_pid);
$_pbg 		= $_product->getData('background')      ;

if(!empty($_pbg))
	$_product_background = $this->helper('catalog/image')->init($_product, 'background'); 

if (empty($_product_background)) {
	$_product_style =  "background:none";
}
else {
	$_product_style = "background:transparent url(".$_product_background.") 50% -20px no-repeat fixed;"; 
  $background_image ="background:none;";
}

?>
<?php
/* Only for Home page */
if(Mage::getSingleton('cms/page')->getIdentifier() == 'home') { ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?php } else{?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<?php }?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->getLang() ?>" lang="<?php echo $this->getLang() ?>">
<head>
<?php echo $this->getChildHtml('head') ?>
</head>
<body<?php echo $this->getBodyClass()?' class="'.$this->getBodyClass().'"':'' ?> style="<?php echo $background_image; ?>">
<div class="wrapper">
    <div class="page" style="<?php echo $_product_style?>">
        <div class="header-container"><?php echo $this->getChildHtml('header');  ?></div>
        <div class="main col2-right-layout clearfix">
            <?php echo $this->getChildHtml('breadcrumbs') ?>
            <div class="col-right sidebar"><?php echo $this->getChildHtml('right') ?></div>

            <div class="col-main"><div  class="leftboxtop"><img src="<?php echo $this->getSkinUrl('images/contenttop.png') ?>" width="706" height="13" alt="2columns-right"  /></div>
                <div class="contpad clearfix">
                <?php echo $this->getChildHtml('global_messages') ?>
                <?php echo $this->getChildHtml('content') ?>
                <?php
/* Only for Home page */
if(Mage::getSingleton('cms/page')->getIdentifier() == 'home') { ?>

                <?php } else{?>
</div> 
<?php }?>

                <img src="<?php echo $this->getSkinUrl('images/contentbottom.gif') ?>" width="706" height="13" alt="2columns-right" />
        </div></div></div>

<div class="clear"></div>
            

            
        


    <div class="footer"><div class="clsfooter-cont">
		<?php echo $this->getChildHtml('footer') ?>

		</div>  <div class="clear"></div>
                </div>
        <?php echo $this->getChildHtml('before_body_end') ?>

<?php //echo $this->getAbsoluteFooter() ?>
    
</body>
</html>